// 引入必要的库
import Vue from 'vue'
import VueI18n from 'vue-i18n'

// 引入工具函数
import { getStorage } from '@/utils/utis'

// 引入项目中需要用到的中英文文案配置js
import enLocale from './en-US'
import cnLocale from './CN'
import zhcnLocale from './zh-CN'
import japcnLocale from './Jap'
import korcnLocale from './Korean'
import ThaiLocal from './Thai'
import SpanishLocal from './Spanish'
import deLocale from "./de"
import frenchLocale from "./French"
import indLocale from "./Indonesian";
import arLocale from "./ar";
import viLocale from "./vi";
import ItalyLocal from './Italy'


// 使用vue-i18n库
Vue.use(VueI18n)

// 获取当前语言（初始化时localStorage里没有存语言，默认为浏览器当前的语言）
const lang = getStorage('lang')  || 'en'
//const lang = 'zh-CN'

// 组合element ui 和 项目自身的文案文件
const messages = {
    'en': {
        ...enLocale
    },
    'CN': {
        ...cnLocale
    },
    'zh-CN': {
        ...zhcnLocale
    },
    'Japanese': {
        ...japcnLocale
    },
    'Korean': {
        ...korcnLocale
    },
    'th': {
        ...ThaiLocal
    },
    'es': {
        ...SpanishLocal
    },
    'de': {
        ...deLocale
    },
    'fr': {
        ...frenchLocale
    },
    'ind': {
        ...indLocale
    },
    'ar': {
        ...arLocale
    },
    'vi': {
        ...viLocale
    },
    'Italy': {
        ...ItalyLocal
    },
}
// 创建vueI18n实例并输出，在main.js中调用
const i18n = new VueI18n({
    fallbackLocale: 'en',
    silentTranslationWarn: true,
    locale: lang,
    messages
})

export default i18n
